package safeCommitter.test.report;

import java.util.Map;
import java.util.TreeMap;

/**
 * Contains all the classes that have already been pushed into the view for
 * update. This is needed for avoiding two classes from being pushed twice into
 * the view.
 * 
 * 
 * @author Luiz Henrique
 * 
 */
public class SCResultRepository {

	private final Map<String, SCClazzTestResult> resultMap = new TreeMap<String, SCClazzTestResult>();

	public ISCClassMethodTestResult getClazzResult(final String clazzName) {
		return resultMap.get(clazzName);
	}

	public Boolean contains(final String clazzName) {
		return resultMap.containsKey(clazzName);
	}

	public SCClazzTestResult addNewClazz(final String clazzName,
			final SCTestResult result, final String fullName) {
		SCClazzTestResult clazzResult = new SCClazzTestResult(clazzName,
				fullName);
		clazzResult.addResult(result);
		resultMap.put(clazzName, clazzResult);
		return clazzResult;
	}

	public SCClazzTestResult addResult(final String clazzName,
			final SCTestResult result) {
		SCClazzTestResult clazzTestResult = resultMap.get(clazzName);
		clazzTestResult.addResult(result);
		return clazzTestResult;

	}

}
